<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org">
<head>
    <th:block th:include="include :: header('修改合作公司')"/>
</head>
<body class="white-bg">
<div class="wrapper wrapper-content animated fadeInRight ibox-content">
    <form class="form-horizontal m" id="form-cooperation-edit" th:object="${chainCooperation}">
        <input name="id" th:field="*{id}" type="hidden">
        <div class="form-group">
            <label class="col-sm-3 control-label is-required">公司名称：</label>
            <div class="col-sm-8">
                <input name="name" th:field="*{name}" class="form-control" type="text" required>
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label is-required">负责人：</label>
            <div class="col-sm-8">
                <div class="input-group">
                    <input id="userId" name="userId" type="hidden" th:value="*{userId}"/>
                    <input class="form-control" type="text" onclick="selectUserIdRadio()" id="userName"
                           readonly="true" th:value="*{userName}" required>
                    <span class="input-group-addon"><i class="fa fa-search"></i></span>
                </div>
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label">地址：</label>
            <div class="col-sm-8">
                <input name="address" th:field="*{address}" class="form-control" type="text">
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label">联系电话：</label>
            <div class="col-sm-8">
                <input name="phone" th:field="*{phone}" class="form-control" type="text">
            </div>
        </div>
    </form>
</div>
<th:block th:include="include :: footer"/>
<script th:inline="javascript">
    var prefix = ctx + "chain/cooperation";
    var userPrefix = ctx + "system/user";
    $("#form-cooperation-edit").validate({
        focusCleanup: true
    });

    function selectUserIdRadio() {
        var options = {
            title: '选择商品库存',
            url: userPrefix + "/selectUser?deptId=107",
            callBack: doUserSubmit
        };
        $.modal.openOptions(options);
    }

    function doUserSubmit(index, layer) {
        var body = $.modal.getChildFrame(index);
        $("#userId").val(body.find("#userId").val());
        $("#userName").val(body.find("#userName").val());
        $.modal.close(index);
    }

    function submitHandler() {
        if ($.validate.form()) {
            $.operate.save(prefix + "/edit", $('#form-cooperation-edit').serialize());
        }
    }

</script>
</body>
</html>